import Vue from 'vue'
import Vuex from 'vuex'
import Router from '@/router'

Vue.use(Vuex)
const store = new Vuex.Store({
	//	strict: true,
	state: {
		// user: {},
		count: 10,
		userListIndex:1,
		orderListAllIndex:1,  //订单列表(全部)
		orderListIndex:1,     //订单列表(客服)
		creditListIndex:1     //授信记录	
	},
	getters: {
        // user: state => state.user,
		getCount: state => state.count,
		getUserListIndex: state => state.userListIndex,
		getOrderListIndex: state => state.orderListIndex, //订单列表(客服)
		getOrderListAllIndex: state => state.orderListAllIndex, //订单列表(全部)
		getCreditListIndex: state => state.getCreditListIndex, //授信记录
	},
	mutations: {
		// set_token:(state, data) =>{
		// 	state.user = data;
		// 	localStorage.setItem('user', JSON.stringify(data));
		// },
		INCREMENT(state) {
			state.count++
		  },
		  DECREMENT(state) {
			state.count--
		  },
		  GETUSERLISTINDEX(state,pageIndex){
			state.userListIndex = pageIndex;
		  },
		  SETORDERLISTINDEX(state,pageIndex){
			state.orderListIndex = pageIndex;
		  },
		  SETORDERLISTALLINDEX(state,pageIndex){
			state.orderListAllIndex = pageIndex;
		  },
		  SETCREDITLISTINDEX(state,pageIndex){
			state.creditListIndex = pageIndex;
		  }
	},
	actions: {
		/*获取订单列表*/
		// get_order_list({
		// 	commit,
		// 	state
		// }) {
		// 	getList({
		// 		sessionId: localStorage.getItem('mytoken'),
		// 	})
		// 	// post('wallet/orders/borrowingInfo', {
		// 	// 	sessionId: state.user.sessionId
		// 	// })
		// 	.then(res => {
		// 		commit('set_order_list', res.data);
		// 	}).catch(res => {
		// 		console.log(res)
		// 	})
		// }
		increment({commit}){
			commit('INCREMENT')
		},
		decrement({commit}){
			commit('DECREMENT')
		},
		getUserListIndex({commit},pageIndex){
			commit('GETUSERLISTINDEX',pageIndex)
		},
		setOrderListIndex({commit},pageIndex){
			commit('SETORDERLISTINDEX',pageIndex)
		},
		setOrderListAllIndex({commit},pageIndex){
			commit('SETORDERLISTALLINDEX',pageIndex)
		},
		setCreditListIndex({commit},pageIndex){
			commit('SETCREDITLISTINDEX',pageIndex)
		}
	}
})

export default store
